package org.metasketch.ham.diagrams;

import javafx.geometry.Orientation;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.ToolBar;

import org.metasketch.diagram.javafx.graphics.DefaultLink;
import org.metasketch.editor.links.GraphicalLinkConfig;
import org.metasketch.editor.links.LinkEndOrientation;
import org.metasketch.editor.links.LinkEndType;
import org.metasketch.editor.links.SemanticConfig;
import org.metasketch.editor.links.SemanticLinkConfig;
import org.metasketch.editor.toolbox.DefaultDiagramBuilder;
import org.metasketch.editor.toolbox.DefaultSelectHandler;
import org.metasketch.editor.toolbox.InheritedRelation;
import org.metasketch.editor.toolbox.SimpleToolBaseDiagramType;
import org.metasketch.ham.diagrams.links.HumanActivityParticipationRelationTypeFactory;
import org.metasketch.ham.diagrams.links.HumanActivityRelationTypeFactory;
import org.metasketch.ham.diagrams.units.ParticipationUnitFactory;
import org.metasketch.ham.model.HumanActivity;
import org.metasketch.ham.model.HumanActivityElement;
import org.metasketch.ham.model.HumanActivityGroup;
import org.metasketch.ham.model.HumanActivityParticipationMap;
import org.metasketch.ham.model.HumanActivityParticipationRelationLink;
import org.metasketch.ham.model.HumanActivityParticipationRelationType;
import org.metasketch.ham.model.HumanActivityRelationLink;
import org.metasketch.ham.model.HumanActivityRelationType;
import org.metasketch.ham.model.HumanOrganizationUnit;
import org.metasketch.ham.model.HumanParticipationElement;
import org.metasketch.ham.model.HumanParticipationGeneralizationLink;
import org.metasketch.ham.model.HumanParticipationGroup;
import org.metasketch.ham.model.HumanParticipationRelationLink;
import org.metasketch.ham.model.HumanParticipationUnit;
import org.metasketch.ham.model.HumanParticipationUnitType;

public class HAMDiagram extends SimpleToolBaseDiagramType {

	public HAMDiagram() {
		super("Human Activity Diagram", new DefaultDiagramBuilder());

		addDefaultDeleteFromDiagramInheritedPopupMenuOption(HumanActivityElement.class);

		addDefaultDeleteFromDiagramInheritedPopupMenuOption(HumanParticipationElement.class);

		addDefaultDeleteFromDiagramInheritedPopupMenuOption(HumanActivityParticipationRelationLink.class);

		registerTool("Select", null, "Select", new DefaultSelectHandler(), null);

		// base activity elements
		registerToolClasses("Activity", null, "HumanActivity-HAD-Node",
				HumanActivity.class, HumanActivityNode.class, true);

		// this is a test
		// registerCallout("Simple Participation Map", null,
		// "Simple-Human-Activity-Participation-Map",
		// "HumanActivity-HAD-Node", HumanActivityNode.class,
		// ParticipationMapNode.class, null, true);

		{
			// the creation of the participation map
			registerToolClasses("Participation", null,
					"Human-Activity-Participation-Map-Node",
					HumanActivityParticipationMap.class,
					ParticipationMapNode.class, true);

			// the link between an activity and a participation map
			GraphicalLinkConfig linkConfigB = new GraphicalLinkConfig();
			linkConfigB.setSourceTypes("HumanActivity-HAD-Node");
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.getSource().setFieldName("participationMaps");

			linkConfigB.setTargetTypes("Human-Activity-Participation-Map-Node");
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			// SemanticConfig cfg = new SemanticConfig();
			// cfg.setSemanticSourceFieldname("participationMaps");

			registerDefaultGraphicalLink("precedes",
					"Human-Activity-Participation-Map-Link", null, linkConfigB);

			// the callout which uses these two tools...
			registerCalloutExt("Participation Map", null, "Participation-Map",
					"Human-Activity-Participation-Map-Node",
					"Human-Activity-Participation-Map-Link");
		}

		registerCalloutExt("Contained Activity Group", null,
				"Contained-Act-Group", "HumanActivityGroup-HAD-Node",
				"Contains-Activity-Relation-HAD-Node");

		registerToolClasses("Activity Group", null,
				"HumanActivityGroup-HAD-Node", HumanActivityGroup.class,
				HumanActivityGroupNode.class, true);

		// participation elements
		// participation units
		registerToolClasses(
				"Role",
				null,
				"Role-Participation-Element-HAD-Node",
				HumanParticipationUnit.class,
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ROLE);",
				HumanParticipationUnitNode.class, true);

		registerToolClasses(
				"Artifact",
				null,
				"Artifact-Participation-Element-HAD-Node",
				HumanParticipationUnit.class,
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ARTIFACT);",
				HumanParticipationUnitNode.class, true);

		registerToolClasses(
				"System",
				null,
				"System-Participation-Element-HAD-Node",
				HumanParticipationUnit.class,
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.SYSTEM);",
				HumanParticipationUnitNode.class, true);

		registerToolClasses(
				"Actor",
				null,
				"Actor-Participation-Element-HAD-Node",
				HumanParticipationUnit.class,
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ACTOR);",
				HumanParticipationUnitNode.class, true);

		registerToolClasses("Participation Group", null,
				"Participation-Group-HAD-Node", HumanParticipationGroup.class,
				ParticipationGroupNode.class, true);

		registerToolClasses("Organization Unit", null,
				"Organization-Unit-HAD-Node", HumanOrganizationUnit.class,
				HumanOrganizationUnitNode.class, true);

		addSemanticalMenuEntry(
				HumanParticipationUnit.class,
				"Role",
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ROLE);");
		addSemanticalMenuEntry(
				HumanParticipationUnit.class,
				"Artifact",
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ARTIFACT);");
		addSemanticalMenuEntry(
				HumanParticipationUnit.class,
				"System",
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.SYSTEM);");
		addSemanticalMenuEntry(
				HumanParticipationUnit.class,
				"Actor",
				"import org.metasketch.ham.model.*; semantic.setType(HumanParticipationUnitType.ACTOR);");

		// activity relationships...
		// precedes
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanActivityElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityRelationLink.class);
			// cfg.setSemanticFactory(new HumanActivityRelationTypeFactory(
			// HumanActivityRelationType.PRECEDES));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.PRECEDES);");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");
			cfg.setSemanticTestScript("import org.metasketch.ham.model.*; return semantic.getType() == HumanActivityRelationType.PRECEDES;");

			registerSemanticLink("precedes",
					"Precedes-Activity-Relation-HAD-Node",
					ActivityRelationshipLink.class, cfg, linkConfigB);
		}

		// concurrent
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanActivityElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityRelationLink.class);
			// cfg.setSemanticFactory(new HumanActivityRelationTypeFactory(
			// HumanActivityRelationType.CONCURRENT));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.CONCURRENT);");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");
			cfg.setSemanticTestScript("import org.metasketch.ham.model.*; return semantic.getType() == HumanActivityRelationType.CONCURRENT;");

			registerSemanticLink("concurrent",
					"Concurrent-Activity-Relation-HAD-Node",
					ActivityRelationshipLink.class, cfg, linkConfigB);
		}

		// INTERLEAVED
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanActivityElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityRelationLink.class);
			// cfg.setSemanticFactory(new HumanActivityRelationTypeFactory(
			// HumanActivityRelationType.INTERLEAVED));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.INTERLEAVED); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");
			cfg.setSemanticTestScript("import org.metasketch.ham.model.*; return semantic.getType() == HumanActivityRelationType.INTERLEAVED;");

			registerSemanticLink("interleaved",
					"Interleaved-Activity-Relation-HAD-Node",
					ActivityRelationshipLink.class, cfg, linkConfigB);
		}

		// contains
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivity.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			// linkConfigB.getSource().getLinkEnd()
			// .setGraphic(LinkEndType.ARROW);

			linkConfigB.setTargetTypes(HumanActivityGroup.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityRelationLink.class);
			// cfg.setSemanticFactory(new HumanActivityRelationTypeFactory(
			// HumanActivityRelationType.CONTAINS));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.CONTAINS); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");
			cfg.setSemanticTestScript("import org.metasketch.ham.model.*; return semantic.getType() == HumanActivityRelationType.CONTAINS;");

			registerSemanticLink("contains",
					"Contains-Activity-Relation-HAD-Node",
					ActivityRelationshipLink.class, cfg, linkConfigB);
		}

		addSemanticalMenuEntry(
				HumanActivityRelationLink.class,
				"Reverse",
				"import org.metasketch.ham.model.*; return semantic.type == HumanActivityRelationType.PRECEDES;",
				null,
				"semantic.source = targetSemantic; semantic.target = sourceSemantic; ",
				"graphic.source = targetGraphic; graphic.target = sourceGraphic; ");

		// addSemanticalMenuEntry(
		// HumanActivityRelationLink.class,
		// "Reverse",
		// "import org.metasketch.ham.model.*; return semantic.type == HumanActivityRelationType.PRECEDES;",
		// "semantic.source = targetSemantic; semantic.target = sourceSemantic; ");
		// //
		// "graphic.source = targetGraphic; graphic.target = sourceGraphic; ");

		addSemanticalMenuEntry(
				HumanActivityRelationLink.class,
				"Precedes",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.PRECEDES);");
		addSemanticalMenuEntry(
				HumanActivityRelationLink.class,
				"Concurrent",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.CONCURRENT);");
		addSemanticalMenuEntry(
				HumanActivityRelationLink.class,
				"Interleaved",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.INTERLEAVED);");
		addSemanticalMenuEntry(
				HumanActivityRelationLink.class,
				"Contains",
				"import org.metasketch.ham.model.*; return (sourceSemantic instanceof HumanActivity && targetSemantic instanceof HumanActivityGroup) || sourceSemantic instanceof HumanActivityGroup && targetSemantic instanceof HumanActivity;",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityRelationType.CONTAINS);  if(targetSemantic instanceof HumanActivity) { semantic.source = targetSemantic;  semantic.target = sourceSemantic; graphic.source = targetGraphic; graphic.target = sourceGraphic;  }");

		// participation relationships
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanParticipationElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanParticipationRelationLink.class);
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("participation link",
					"Participation-Relation-HAD-Node", ParticipationLink.class,
					cfg, linkConfigB);
		}

		// inheritance/generalization link
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanParticipationElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.getTarget().getLinkEnd()
					.setGraphic(LinkEndType.TRIANGLE);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanParticipationGeneralizationLink.class);
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("generalization link",
					"Participation-Generalization-Relation-HAD-Node",
					DefaultLink.class, cfg, linkConfigB);
		}

		addSemanticalMenuEntry(
				HumanParticipationGeneralizationLink.class,
				"Reverse",
				null,
				null,
				"semantic.source = targetSemantic; semantic.target = sourceSemantic; ",
				"graphic.source = targetGraphic; graphic.target = sourceGraphic; ");

		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"No arrows",
				"semantic.setShowSourceArrow(false); semantic.setShowTargetArrow(false);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Source Arrow",
				"semantic.setShowSourceArrow(true); semantic.setShowTargetArrow(false);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Target Arrow",
				"semantic.setShowSourceArrow(false); semantic.setShowTargetArrow(true);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Both Arrows",
				"semantic.setShowSourceArrow(true); semantic.setShowTargetArrow(true);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"No labels",
				"semantic.setShowSourceLabel(false); semantic.setShowTargetLabel(false);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Source Label",
				"semantic.setShowSourceLabel(true); semantic.setShowTargetLabel(false);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Target Label",
				"semantic.setShowSourceLabel(false); semantic.setShowTargetLabel(true);");
		addSemanticalMenuEntry(HumanParticipationRelationLink.class,
				"Both Labels",
				"semantic.setShowSourceLabel(true); semantic.setShowTargetLabel(true);");

		// hybrid relationships

		// uses
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityParticipationRelationLink.class);
			// cfg.setSemanticFactory(new
			// HumanActivityParticipationRelationTypeFactory(
			// HumanActivityParticipationRelationType.USES));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.USES); ");

			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("uses",
					"Activity-Participation-Uses-Relation-HAD-Node",
					HybridRelationshipLink.class, cfg, linkConfigB);
		}

		// input
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityParticipationRelationLink.class);
			// cfg.setSemanticFactory(new
			// HumanActivityParticipationRelationTypeFactory(
			// HumanActivityParticipationRelationType.INPUT));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.INPUT); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("input",
					"Activity-Participation-Input-Relation-HAD-Node",
					HybridRelationshipLink.class, cfg, linkConfigB);
		}

		// output
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityParticipationRelationLink.class);
			// cfg.setSemanticFactory(new
			// HumanActivityParticipationRelationTypeFactory(
			// HumanActivityParticipationRelationType.OUTPUT));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.OUTPUT); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("output",
					"Activity-Participation-Output-Relation-HAD-Node",
					HybridRelationshipLink.class, cfg, linkConfigB);
		}

		// initiates
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityParticipationRelationLink.class);
			// cfg.setSemanticFactory(new
			// HumanActivityParticipationRelationTypeFactory(
			// HumanActivityParticipationRelationType.INITIATES));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.INITIATES); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("initiates",
					"Activity-Participation-Initiates-Relation-HAD-Node",
					HybridRelationshipLink.class, cfg, linkConfigB);
		}

		// executes
		{
			SemanticLinkConfig linkConfigB = new SemanticLinkConfig();
			linkConfigB.setInherited(true);
			linkConfigB.setSourceTypes(HumanActivityElement.class);
			linkConfigB.getSource().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);
			linkConfigB.setTargetTypes(HumanParticipationElement.class);
			linkConfigB.getTarget().getLinkEnd()
					.setOrientation(LinkEndOrientation.CLOSEST);

			SemanticConfig cfg = new SemanticConfig();
			cfg.setSemanticType(HumanActivityParticipationRelationLink.class);
			// cfg.setSemanticFactory(new
			// HumanActivityParticipationRelationTypeFactory(
			// HumanActivityParticipationRelationType.EXECUTES));
			cfg.setSemanticBuildScript("import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.EXECUTES); ");
			cfg.setLinkSourceFieldname("source");
			cfg.setLinkTargetFieldname("target");

			registerSemanticLink("executes",
					"Activity-Participation-Executes-Relation-HAD-Node",
					HybridRelationshipLink.class, cfg, linkConfigB);
		}

		addSemanticalMenuEntry(
				HumanActivityParticipationRelationLink.class,
				"Uses",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.USES);");

		addSemanticalMenuEntry(
				HumanActivityParticipationRelationLink.class,
				"Input",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.INPUT);");
		addSemanticalMenuEntry(
				HumanActivityParticipationRelationLink.class,
				"Output",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.OUTPUT);");
		addSemanticalMenuEntry(
				HumanActivityParticipationRelationLink.class,
				"Initiates",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.INITIATES);");
		addSemanticalMenuEntry(
				HumanActivityParticipationRelationLink.class,
				"Executes",
				"import org.metasketch.ham.model.*; semantic.setType(HumanActivityParticipationRelationType.EXECUTES);");

		// adding child/parent relations

		relationManager.register(new InheritedRelation(
				HumanActivityElement.class, HumanActivityGroup.class, null,
				"humanActivityElements"));

		relationManager.register(new InheritedRelation(
				HumanParticipationElement.class, HumanParticipationGroup.class,
				null, "participationElements"));

		relationManager.register(new InheritedRelation(
				HumanActivityElement.class, HumanOrganizationUnit.class, null,
				"humanActivityElements"));

		// for callouts
		relationManager.register(new InheritedRelation(
				HumanParticipationElement.class, HumanActivity.class, null,
				"participationElements"));

		relationManager.register(new InheritedRelation(
				HumanParticipationElement.class,
				HumanActivityParticipationMap.class, null,
				"participationElements"));

	}

	@Override
	public ToolBar createToolbar() {

		ToolBar toolBar = new ToolBar(
				getTypeButton("Select"),

				new Label("Activities"),
				getTypeButton("HumanActivity-HAD-Node"),
				getTypeButton("HumanActivityGroup-HAD-Node"),
				getTypeButton("Contained-Act-Group"),
				// getTypeButton("Simple-Human-Activity-Participation-Map"),
				getTypeButton("Participation-Map"),

				getTypeButton("Precedes-Activity-Relation-HAD-Node"),
				getTypeButton("Concurrent-Activity-Relation-HAD-Node"),
				getTypeButton("Interleaved-Activity-Relation-HAD-Node"),
				getTypeButton("Contains-Activity-Relation-HAD-Node"),

				new Separator(),
				new Label("Participation"),
				getTypeButton("Role-Participation-Element-HAD-Node"),
				getTypeButton("System-Participation-Element-HAD-Node"),
				getTypeButton("Artifact-Participation-Element-HAD-Node"),
				getTypeButton("Actor-Participation-Element-HAD-Node"),

				getTypeButton("Participation-Group-HAD-Node"),

				getTypeButton("Participation-Relation-HAD-Node"),
				getTypeButton("Participation-Generalization-Relation-HAD-Node"),

				new Separator(),
				new Label("Misc"),
				getTypeButton("Activity-Participation-Uses-Relation-HAD-Node"),
				getTypeButton("Activity-Participation-Input-Relation-HAD-Node"),
				getTypeButton("Activity-Participation-Output-Relation-HAD-Node"),
				getTypeButton("Activity-Participation-Initiates-Relation-HAD-Node"),
				getTypeButton("Activity-Participation-Executes-Relation-HAD-Node"),

				getTypeButton("Organization-Unit-HAD-Node")

		);

		toolBar.setOrientation(Orientation.VERTICAL);

		return toolBar;
	}
}
